﻿using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace CodeContrib.Hydrator
{
	public static class DefaultTypeMap
	{
		private static readonly IList<IMap> _mappings;

		public static IList<IMap> Mappings
		{
			get { return _mappings; }
		}

		static DefaultTypeMap()
		{
			_mappings = new List<IMap>();
			_mappings.Add(new Map<bool>(new RandomBoolean()));
			_mappings.Add(new Map<DateTime>(new RandomSqlDateTime()));
			_mappings.Add(new Map<decimal>(new RandomDecimal()));
			_mappings.Add(new Map<Decimal>(new RandomDecimal()));
			_mappings.Add(new Map<double>(new RandomDouble()));
			_mappings.Add(new Map<Double>(new RandomDouble()));
			_mappings.Add(new EnumMap());
			_mappings.Add(new Map<Guid>(new RandomGuid()));
			_mappings.Add(new Map<int>(new RandomInteger()));
			_mappings.Add(new Map<Int32>(new RandomInteger()));
			_mappings.Add(new Map<string>(new RandomWord()));
			_mappings.Add(new Map<string>(new RandomCompanyName()).Matching(x => Regex.IsMatch(x.Name, "(company|business)", RegexOptions.IgnoreCase)));
			_mappings.Add(new Map<string>(new RandomFirstName()).Matching(x => Regex.IsMatch(x.Name, "(firstname|fname)", RegexOptions.IgnoreCase)));
			_mappings.Add(new Map<string>(new RandomLastName()).Matching(x => Regex.IsMatch(x.Name, "(lastname|lname)", RegexOptions.IgnoreCase)));
			_mappings.Add(new Map<string>(new RandomGender()).Matching(x => Regex.IsMatch(x.Name, "gender", RegexOptions.IgnoreCase)));
			_mappings.Add(new Map<string>(new RandomPassword()).Matching(x => Regex.IsMatch(x.Name, "password", RegexOptions.IgnoreCase)));
			_mappings.Add(new Map<string>(new RandomEmailAddress()).Matching(x => Regex.IsMatch(x.Name, "email", RegexOptions.IgnoreCase)));
			_mappings.Add(new Map<string>(new RandomUrl()).Matching(x => Regex.IsMatch(x.Name, "(homepage|webpage|website|url)", RegexOptions.IgnoreCase)));
			_mappings.Add(new Map<string>(new RandomIpAddress()).Matching(x => Regex.IsMatch(x.Name, "ipaddress", RegexOptions.IgnoreCase)));
		}
	}
}